/**
 * hh:mm 或者 hh:mm:ss
 */
let arr = [
  "00",
  "01",
  "02",
  "03",
  "04",
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "12",
  "13",
  "14",
  "15",
  "16",
  "17",
  "18",
  "19",
  "20",
  "21",
  "22",
  "23",
];
let arr2 = [
  "00",
  "01",
  "02",
  "03",
  "04",
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "12",
  "13",
  "14",
  "15",
  "16",
  "17",
  "18",
  "19",
  "20",
  "21",
  "22",
  "23",
  "24",
  "25",
  "26",
  "27",
  "28",
  "29",
  "30",
  "31",
  "32",
  "33",
  "34",
  "35",
  "36",
  "37",
  "38",
  "39",
  "40",
  "41",
  "42",
  "43",
  "44",
  "45",
  "46",
  "47",
  "48",
  "49",
  "50",
  "51",
  "52",
  "53",
  "54",
  "55",
  "56",
  "57",
  "58",
  "59",
];

//判断时分数组的内容
export const periodOfTime = (hour: any, min: any) => {
  let newHours = arr.slice(0, hour + 1);
  let newMinutes = arr2.slice(0, min + 1);
  return time(newHours, newMinutes);
};
export const time = (arr: string[], arr2: string[]) => {
  let len1 = arr.length;
  let len2 = arr2.length;
  let end = [];
  let r = 0;
  while (r < len1) {
    for (let l = 0; l < len2; l++) {
      end.push(arr[r] + ":" + arr2[l]);
    }
    r++;
    continue;
  }
  return end;
};

/**
 * 生成时间格式基础字符串数组
 * 生成24小时的数组 num=24
 * 生成60分钟的数组 num=60
 */
export const timeArr = function (num: number) {
  let arr = [];
  for (let i = 0, j = num + 1; i < j; i++) {
    if (i < 10) {
      arr.push("0" + i);
    } else {
      arr.push("" + i);
    }
  }
  return arr;
};
